/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.cggveritas.crewintranet.jms.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author Alassane
 */
@Entity
@Table(name = "cv_model")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CvModel.findAll", query = "SELECT c FROM CvModel c"),
    @NamedQuery(name = "CvModel.findByIdmodel", query = "SELECT c FROM CvModel c WHERE c.idmodel = :idmodel"),
    @NamedQuery(name = "CvModel.findByModel", query = "SELECT c FROM CvModel c WHERE c.model = :model")})
public class CvModel implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idmodel")
    private Integer idmodel;
    @Column(name = "model")
    private String model;
    @JoinColumn(name = "cv_marque_idmarque", referencedColumnName = "idmarque")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private CvMarque cvMarqueIdmarque;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cvModelIdmodel", fetch = FetchType.LAZY)
    private List<CvTypemodel> cvTypemodelList;
    @OneToMany(mappedBy = "cvModelIdmodel", fetch = FetchType.LAZY)
    private List<CvVehicule> cvVehiculeList;

    public CvModel() {
    }

    public CvModel(Integer idmodel) {
        this.idmodel = idmodel;
    }

    public Integer getIdmodel() {
        return idmodel;
    }

    public void setIdmodel(Integer idmodel) {
        this.idmodel = idmodel;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public CvMarque getCvMarqueIdmarque() {
        return cvMarqueIdmarque;
    }

    public void setCvMarqueIdmarque(CvMarque cvMarqueIdmarque) {
        this.cvMarqueIdmarque = cvMarqueIdmarque;
    }

    @XmlTransient
    @JsonIgnore
    public List<CvTypemodel> getCvTypemodelList() {
        return cvTypemodelList;
    }

    public void setCvTypemodelList(List<CvTypemodel> cvTypemodelList) {
        this.cvTypemodelList = cvTypemodelList;
    }

    @XmlTransient
    @JsonIgnore
    public List<CvVehicule> getCvVehiculeList() {
        return cvVehiculeList;
    }

    public void setCvVehiculeList(List<CvVehicule> cvVehiculeList) {
        this.cvVehiculeList = cvVehiculeList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idmodel != null ? idmodel.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CvModel)) {
            return false;
        }
        CvModel other = (CvModel) object;
        if ((this.idmodel == null && other.idmodel != null) || (this.idmodel != null && !this.idmodel.equals(other.idmodel))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.cggveritas.crewintranet.jms.entities.CvModel[ idmodel=" + idmodel + " ]";
    }
    
}
